home *** CD-ROM | disk | FTP | other *** search
/ Champak 83 / (Vol 83) My Disc.iso / Games / bee_game.swf / scripts / frame_12 / DoAction.as
Text File  |  2008-08-07  |  6KB  |  285 lines

  1. function bunga_init(nomor)
  2. {
  3.    var objbunga = _root["bunga" + nomor];
  4.    objbunga.hidup = true;
  5.    objbunga._alpha = 100;
  6.    objbunga.disedot = false;
  7.    objbunga.onEnterFrame = function()
  8.    {
  9.       if(!isPaused)
  10.       {
  11.          objbunga.cekbunga = false;
  12.          if(objbunga.hidup and objbunga.perimeter.hitTest(player.perimeter))
  13.          {
  14.             objbunga.cekbunga = true;
  15.          }
  16.          if(!objbunga.hidup and objbunga._alpha > 0)
  17.          {
  18.             objbunga._alpha -= 10;
  19.          }
  20.          if(!objbunga.hidup and objbunga.disedot)
  21.          {
  22.             diam = false;
  23.          }
  24.       }
  25.    };
  26. }
  27. function web_init(nomor)
  28. {
  29.    var objweb = _root["web" + nomor];
  30.    objweb.hidup = true;
  31.    objweb._alpha = 100;
  32.    objweb.posisi = nomor;
  33.    objweb.onEnterFrame = function()
  34.    {
  35.       if(!isPaused)
  36.       {
  37.          objweb.cekweb = false;
  38.          if(objweb.hidup and objweb.perimeter.hitTest(player.perimeter))
  39.          {
  40.             webnomor = objweb.posisi;
  41.             player._x = objweb._x;
  42.             player._y = objweb._y;
  43.             objweb.cekweb = true;
  44.             diam2 = true;
  45.          }
  46.          if(!objweb.hidup and objweb._alpha > 0)
  47.          {
  48.             objweb._alpha -= 10;
  49.          }
  50.       }
  51.    };
  52. }
  53. function init()
  54. {
  55.    pause_menu._visible = false;
  56.    isPaused = false;
  57.    stage_sound.stop();
  58.    if(suara)
  59.    {
  60.       stage_sound2.start(0,20000);
  61.    }
  62.    level = 1;
  63.    player._xscale = 130;
  64.    player._yscale = 130;
  65.    start_ani._visible = true;
  66.    completed_ani._visible = false;
  67.    start_ani.gotoAndPlay(1);
  68.    completed_ani.gotoAndStop(1);
  69.    modegame = 1;
  70.    nectarbar._alpha = 0;
  71.    webbar._alpha = 0;
  72.    timerkebal = 0;
  73.    diam = false;
  74.    diam2 = false;
  75.    jmlnectar = 0;
  76.    hpbunga = 20;
  77.    hpplayer = maxhplayer;
  78.    hppanel.gotoAndStop(hpplayer);
  79.    target = 4;
  80.    speed = 0;
  81.    topspeed = 5 + lvmove * 2;
  82.    accel = lvmove;
  83.    jumweb = 5;
  84.    jumbunga = 4;
  85.    jumpohon = 11;
  86.    jumlalat = 0;
  87.    time = 1000;
  88.    var _loc1_ = 1;
  89.    while(_loc1_ <= jumbunga)
  90.    {
  91.       bunga_init(_loc1_);
  92.       _loc1_ = _loc1_ + 1;
  93.    }
  94.    _loc1_ = 1;
  95.    while(_loc1_ <= jumweb)
  96.    {
  97.       web_init(_loc1_);
  98.       _loc1_ = _loc1_ + 1;
  99.    }
  100. }
  101. function looputama()
  102. {
  103.    hppanel.gotoAndStop(hpplayer);
  104.    waktu = Math.ceil(time / 25);
  105.    tulisan = jmlnectar + " / " + target;
  106.    player.body._visible = true;
  107.    player.bintang._visible = false;
  108.    if(!(start_ani._visible or completed_ani._visible))
  109.    {
  110.       if(Key.isDown(80))
  111.       {
  112.          pause_menu._visible = false;
  113.          pause_menu._y = -600;
  114.          if(!pausepressed)
  115.          {
  116.             isPaused = !isPaused;
  117.             pausepressed = true;
  118.          }
  119.          if(isPaused)
  120.          {
  121.             pause_menu._visible = true;
  122.             pause_menu._y = -31.7;
  123.          }
  124.       }
  125.       else
  126.       {
  127.          pausepressed = false;
  128.       }
  129.    }
  130.    if(time <= 0)
  131.    {
  132.       gayamati = 2;
  133.       gotoAndStop("gameover");
  134.       delete onEnterFrame;
  135.    }
  136.    if(hpplayer <= 0)
  137.    {
  138.       gayamati = 3;
  139.       gotoAndStop("gameover");
  140.       delete onEnterFrame;
  141.    }
  142.    if(Key.isDown(77))
  143.    {
  144.       if(!musicpressed)
  145.       {
  146.          suara = !suara;
  147.          musicpressed = true;
  148.          stage_sound.stop();
  149.          if(suara)
  150.          {
  151.             stage_sound2.start(0,20000);
  152.          }
  153.       }
  154.    }
  155.    else
  156.    {
  157.       musicpressed = false;
  158.    }
  159.    if(Key.isDown(32))
  160.    {
  161.       diam = false;
  162.    }
  163.    var _loc4_ = _xmouse - player._x;
  164.    var _loc3_ = _ymouse - player._y;
  165.    angle = Math.atan2(_loc3_,_loc4_);
  166.    if(Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_) > 20)
  167.    {
  168.       speed += accel;
  169.       if(speed > topspeed)
  170.       {
  171.          speed = topspeed;
  172.       }
  173.    }
  174.    else
  175.    {
  176.       speed = 0;
  177.    }
  178.    if(!(start_ani._visible or completed_ani._visible or isPaused))
  179.    {
  180.       time--;
  181.       var _loc2_ = 1;
  182.       while(_loc2_ <= jumlalat)
  183.       {
  184.          _root["lalat" + _loc2_].play();
  185.          _loc2_ = _loc2_ + 1;
  186.       }
  187.       if(!(diam or diam2))
  188.       {
  189.          player._rotation = angle * 180 / 3.141592653589793;
  190.          player._x += Math.cos(angle) * speed;
  191.          player._y += Math.sin(angle) * speed;
  192.          player._xscale = 130;
  193.          player._yscale = 130;
  194.       }
  195.       else
  196.       {
  197.          player._xscale = 90;
  198.          player._yscale = 90;
  199.       }
  200.       if(!diam)
  201.       {
  202.          if(nectarbar._alpha > 0)
  203.          {
  204.             nectarbar._alpha -= 20;
  205.          }
  206.          timerbar = 0;
  207.       }
  208.       else
  209.       {
  210.          if(nectarbar._alpha < 100)
  211.          {
  212.             nectarbar._alpha += 20;
  213.          }
  214.          if(timerbar > 0)
  215.          {
  216.             timerbar -= 0.15;
  217.          }
  218.          else
  219.          {
  220.             timerbar = 0;
  221.          }
  222.          nectarbar.bar._xscale = timerbar / hpbunga * 100;
  223.       }
  224.       if(!diam2)
  225.       {
  226.          if(webbar._alpha > 0)
  227.          {
  228.             webbar._alpha -= 20;
  229.          }
  230.          timerbar2 = 10;
  231.       }
  232.       else
  233.       {
  234.          if(webbar._alpha < 100)
  235.          {
  236.             webbar._alpha += 20;
  237.          }
  238.          if(timerbar2 > 0)
  239.          {
  240.             timerbar2 -= 0.15;
  241.          }
  242.          else
  243.          {
  244.             timerbar2 = 0;
  245.             gayamati = 1;
  246.             gotoAndStop("gameover");
  247.             delete onEnterFrame;
  248.          }
  249.          webbar.bar._xscale = timerbar2 / 20 * 100;
  250.       }
  251.       if(timerkebal > 0)
  252.       {
  253.          player.bintang._visible = true;
  254.          timerkebal--;
  255.          if(timerkebal % 2 == 1)
  256.          {
  257.             player.body._visible = false;
  258.          }
  259.       }
  260.    }
  261.    else
  262.    {
  263.       _loc2_ = 1;
  264.       while(_loc2_ <= jumlalat)
  265.       {
  266.          _root["lalat" + _loc2_].stop();
  267.          _loc2_ = _loc2_ + 1;
  268.       }
  269.    }
  270.    _loc2_ = 1;
  271.    while(_loc2_ <= jumpohon)
  272.    {
  273.       _root["pohon" + _loc2_].daun_gerak._visible = false;
  274.       if(player.perimeter.hitTest(_root["pohon" + _loc2_].perimeter))
  275.       {
  276.          speed *= 0.5;
  277.          _root["pohon" + _loc2_].daun_gerak._visible = true;
  278.       }
  279.       _loc2_ = _loc2_ + 1;
  280.    }
  281. }
  282. stop();
  283. init();
  284. onEnterFrame = looputama;
  285.